#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/7/12 11:28
# @Author : 闫峰
# @File    : sku_change_to_listing_update.py


import os
import time
from common.setting import ensure_path_sep
from utils.logging_tool.log_control import LogHandler
from utils.mysqlUtils.db_pool import Database

current_path = os.path.abspath(__file__)
current_dir = os.path.dirname(current_path)
path_list = current_path.split("\\")
dis_path = "\\".join(path_list[-2:-1])


def remove_file(info_path):
    if os.path.exists(info_path):
        os.remove(info_path)
    else:
        print(f"{info_path} 不存在")


info_path = ensure_path_sep(f"\\logs\\info-{dis_path}{time.time()}")
error_path = ensure_path_sep(f"\\logs\\\error-{dis_path}{time.time()}.log")
warning_path = ensure_path_sep(f"\\logs\\warning-{dis_path}{time.time()}.log")
remove_file(info_path)
remove_file(error_path)
remove_file(warning_path)
INFO = LogHandler(info_path, level='info')
ERROR = LogHandler(error_path, level='error')
WARNING = LogHandler(warning_path, level='warning')


class TestA:
    znkd_db = Database(ensure_path_sep("\\config\\znkd_mysql_config.yaml"), "znkd_database_prod")
    def test_(self):
        """
        产品库更新 引起listing变更
        :return:
        """
        a = ['16842759', '4325384', '17268746', '12697619', '15556645', '17367085', '16130097', '17457207', '7192649', '6701132', '8331340', '10584145', '5283921', '2555988', '2842710', '10412120', '10371160', '7659613', '17637483', '5513328', '14000242', '17137782', '9240697', '9117817', '15581307', '14737552', '10764432', '10223770', '16720028', '16859297', '17391780', '14041258', '12779704', '11264189', '10969281', '16195796', '13369559', '17375448', '15974619', '9978078', '17645791', '12263652', '12779751', '11968750', '17105134', '4292847', '2138360', '17367289', '12697849', '9388284', '7119108', '10584326', '17105171', '12747035', '17088796', '13263133', '12689695', '12591392', '14164260', '13197605', '13017387', '11829553', '17056049', '9707830', '2130231', '12779840', '16654661', '16056658', '14459221', '6652247', '14082401', '8053098', '16613739', '17613173', '3744127', '16261513', '4505998', '16679312', '17383835', '15450539', '5407147', '16097710', '17449395', '11084221', '15598014', '16900543', '9912774', '6701530', '9667038', '16056810', '6701557', '16384510', '2867720', '6652425', '17318410', '6701583', '5595664', '15778328', '7119386', '14893596', '11772445', '15475232', '12296747', '15450668', '15475243', '17515051', '17621552', '16794168', '4825660', '14033472', '16147009', '13435457', '6308420', '9658957', '13967949', '9871962', '17449585', '16245361', '7119481', '7750270', '17089159', '10584723', '16368276', '9839255', '17384093', '17089185', '13443748', '17146536', '5096105', '15557294', '6677182', '9052864', '14402255', '8946385', '7340775', '7537384', '16917235', '17621747', '2450163', '15835903', '6677250', '14754566', '15729420', '11772692', '7537431', '9855771', '10887969', '6677290', '12788531', '7537464', '17351483', '11281214', '17490754', '6677315', '5251908', '3760965', '3760975', '16868177', '14328659', '6693719', '17146713', '9659225', '16991076', '7537510', '6931309', '14418800', '6701941', '4359039', '7537542', '6652808', '17269647', '6931344', '17089425', '7537554', '13370264', '7537570', '7537579', '17482673', '16679860', '7537589', '6931383', '17089469', '17269695', '1524686', '15557591', '2819037', '14451677', '17490919', '13173739', '12592107', '6931436', '17089518', '12092405', '15999999', '12174345', '10429457', '16524313', '17171481', '14418973', '15459364', '14894117', '17269814', '13354042', '16524348', '16098368', '14910530', '16876612', '11732036', '11650121', '17540175', '15459412', '9479255', '16082009', '17392741', '8152172', '1934444', '12035193', '11216002', '2696322', '6702224', '15910033', '2172052', '7300248', '8766618', '17499297', '13206690', '4285619', '17269941', '12010687', '15959234', '13911236', '17171653', '17269959', '3589322', '8914128', '9389270', '6702301', '17679592', '4433132', '16352496', '15426807', '16409862', '15557899', '15049995', '5956886', '3056922', '17425694', '13501729', '17245479', '16925991', '1664296', '17548596', '12723508', '13288764', '13731136', '5776707', '10937675', '17638735', '6702420', '15582563', '16123236', '6669669', '5956977', '8160638', '16991622', '13772173', '5957023', '17679776', '17679784', '9962920', '16926122', '17450414', '5957044', '8340920', '16655802', '2549182', '17622466', '4253131', '16410060', '9340364', '3057102', '16328145', '6702546', '16655829', '16655835', '8357342', '16623084', '12002803', '12183041', '6587908', '6587911', '17458698', '6702606', '16795162', '17057307', '11339297', '13059627', '15959598', '16631346', '3352116', '17188410', '6702657', '16410195', '7824989', '4499042', '16631395', '16901737', '14616175', '10626700', '9307794', '16377491', '15861396', '17450654', '13215395', '6702756', '17491628', '9946803', '17491642', '6702792', '5613259', '16246481', '17352411', '14616287', '15935202', '12723938', '1836776', '15910633', '9996009', '10397421', '4941553', '6973169', '10061553', '13715189', '3368700', '17450753', '8177412', '13813514', '10233612', '6326036', '11626262', '10921751', '16271126', '16459551', '17368865', '17524514', '11044641', '16631588', '17188646', '17557289', '16459592', '8644434', '5580634', '10610526', '16672617', '14165878', '1615751', '3155849', '16533388', '16476068', '8390570', '3082185', '16746449', '15828947', '10635223', '16918502', '14608367', '9570287', '4007924', '17647606', '11257852', '4761599', '17336325', '16590866', '17344539', '16640031', '17549352', '7456813', '7456821', '7456823', '14329912', '17426490', '7456828', '7456829', '7456830', '2918464', '15550532', '2697285', '3106888', '15550539', '1607761', '17287251', '9463924', '16001149', '8226956', '16050327', '9234583', '10045593', '16156823', '17025207', '7538908', '9996508', '17459424', '12028130', '16419049', '16582890', '17254635', '16910597', '16877830', '14035206', '16050448', '4483346', '2386200', '2779421', '15911199', '6244645', '3967273', '6818098', '6818099', '16050488', '16050489', '16050490', '15796546', '17508683', '3344719', '15878481', '16542033', '16066898', '15911261', '17574249', '6203761', '15911285', '15911288', '15919483', '15542657', '16165254', '2435470', '17574288', '1690011', '17344927', '12642728', '6203821', '14510541', '16640463', '9497040', '7522769', '14567897', '16157157', '12724715', '15919597', '12577267', '11463158', '17377788', '15796736', '3344896', '16017926', '15780360', '9759263', '16755248', '11774527', '14166605', '17025615', '7367248', '12749392', '12831329', '17336934', '9734762', '8481394', '9439863', '8702586', '10349178', '16018045', '10373757', '16837251', '13519492', '16140933', '12708494', '15796882', '16681625', '17123994', '8620697', '16018079', '17377958', '11995823', '8104625', '12847799', '17230527', '6064832', '15887041', '14666433', '12749507', '14592722', '7531218', '17214164', '17427162', '10865380', '15936232', '12831466', '17369848', '17042172', '17648395', '17369870', '10865429', '17607446', '15428387', '6966052', '14650151', '11078451', '10447671', '16780092', '17279808', '15428455', '17648489', '14887787', '15928177', '14666609', '4377461', '16681850', '14666623', '17279876', '10374021', '17566601', '14715798', '12503976', '9522098', '8645559', '10677192', '10054600', '6695882', '17238995', '9522137', '11070429', '13732835', '15920105', '17607658', '17599467', '16354287', '11004912', '10865648', '16632820', '15920117', '15043597', '17083407', '13184022', '15559716', '15928361', '16247861', '2632758', '17173559', '12201014', '6720571', '17083452', '9489479', '13864021', '17607770', '17091679', '15920225', '16329829', '9686120', '3886185', '15920239', '15920241', '15920244', '15862907', '13405311', '16673921', '13274244', '7400581', '14986373', '16329867', '16329868', '16886932', '10685590', '13585559', '16166057', '4304044', '14830781', '15912125', '13585605', '15805637', '10849480', '16780488', '2288846', '16166105', '15912161', '12758259', '15985908', '13659381', '15912181', '7711997', '14454015', '14789891', '14789894', '15912198', '15805704', '13626658', '17509667', '15559977', '3296565', '13479237', '14093641', '7589196', '14986574', '16215379', '12791124', '14454101', '17427800', '10759512', '8449377', '3059042', '16887139', '17509733', '7589222', '17550697', '16035185', '14454130', '9858426', '17501584', '16330128', '11152796', '15044008', '17550762', '4361644', '16887215', '17272243', '4181428', '15969718', '17198523', '16051643', '17427904', '15781314', '16027074', '17419716', '13299147', '7605728', '17559011', '17542631', '17542632', '16592367', '17321463', '14724600', '16158201', '2354681', '11922939', '11251214', '16158236', '17550883', '16543268', '13110820', '13315619', '10309167', '10333745', '17542712', '8367681', '17542722', '17051203', '16158281', '17215051', '7302734', '4034142', '11284066', '8875620', '17256039', '11013735', '17198701', '16944754', '16862844', '15740548', '17002122', '5369483', '17542796', '12660367', '17542805', '16150195', '17542837', '16543416', '16666305', '17518281', '15937226', '15896273', '16051921', '17206995', '13823698', '17026780', '17583842', '17542895', '3059444', '15740660', '9613046', '15740663', '17518335', '16051969', '11898634', '3895053', '2903824', '16174867', '17526554', '11710236', '13823779', '13266727', '2830121', '2871100', '17452861', '17125191', '1847113', '10096460', '3166029', '11013966', '8818509', '17370968', '16944985', '2600792', '15585121', '17543013', '1994599', '17198955', '16789359', '5926774', '16002946', '11775875', '14741381', '10694537', '15544212', '17461140', '17379230', '17543075', '17215409', '4566967', '17543100', '12931004', '11235266', '16789443', '5189572', '10506186', '10735567', '14708689', '16396245', '17543129', '17010652', '3059677', '4345826', '12054501', '8548329', '17494015', '10539008', '9605136', '2650131', '9916449', '12013613', '16117811', '14618677', '17403961', '17403966', '10694721', '14626882', '8474693', '7974982', '12578891', '12046415', '10874989', '3813490', '16748666', '7098498', '4403331', '10612869', '14037130', '2584717', '10948751', '16044176', '10776722', '11554964', '15863987', '13979838', '9859269', '17002707', '17559772', '12243164', '17133792', '15560930', '16150757', '17178619', '6271214', '10785012', '12030204', '16748803', '16158982', '17019146', '4018445', '12759316', '17543457', '11161894', '17199423', '2298182', '9548103', '5574999', '14954853', '14668146', '14930296', '12767610', '10670462', '7025025', '10981765', '15561094', '14897543', '10744200', '12693893', '6173071', '17494416', '12800400', '16945561', '16118171', '3445153', '12497320', '17641899', '12693934', '17420726', '16888257', '7139777', '16945607', '2118090', '11653580', '17183180', '2118101', '14897622', '3756504', '15913433', '17543645', '12235230', '15561202', '10482166', '15512058', '4674043', '17388030', '16601607', '12333580', '2798109', '17543713', '6795817', '14987818', '12079660', '8770096', '17142324', '7615029', '15626808', '5493305', '16036411', '15446588', '17011261', '17330758', '14389835', '10580557', '2798162', '16036455', '16601705', '16495214', '15626862', '2798198', '12825209', '13980282', '15118970', '14922379', '2798219', '15553178', '17142429', '17429157', '10449574', '15119017', '15119021', '13824687', '17216181', '15880889', '15913658', '3191483', '16601789', '10474177', '2568900', '17060553', '2568907', '16282331', '16495329', '15979236', '16118512', '13578998', '15938295', '1643258', '17011477', '4322074', '17543963', '9204508', '17126186', '17175349', '10662710', '6878006', '16921401', '17208128', '17650498', '3519309', '4756313', '12743533', '10810234', '2659201', '14316427', '16634766', '8475539', '17314724', '17314767', '16864212', '8483803', '16733148', '16864220', '7328734', '12825567', '13595616', '2618344', '2348010', '17069038', '16692207', '13825019', '17208330', '17134603', '16045080', '9565209', '17380378', '17167386', '6018078', '12727331', '16929834', '17650737', '16118835', '8041525', '16839738', '17323071', '2356288', '5813318', '2372678', '12776518', '16839758', '17650799', '17118324', '12776564', '16872567', '12850314', '8828042', '9606289', '16053399', '15602841', '10728606', '14365858', '16897189', '16659627', '8516793', '16790716', '16192705', '17118406', '6272211', '17061075', '2790616', '15512794', '16053466', '17118428', '8525037', '17650927', '17601776', '17265917', '2602247', '12637447', '12743948', '9737493', '8746261', '15602975', '15602981', '15602982', '10851626', '16626991', '17560892', '16127301', '17487174', '16127304', '16954714', '10040670', '11752801', '17036642', '6493538', '17216876', '17175926', '12940662', '14505351', '17397134', '17626527', '14415273', '2028995', '3061187', '2455002', '6837743', '7976444', '17643012', '7976453', '5592584', '15087118', '15922708', '17307162', '15652393', '9705008', '10819134', '16127561', '11949642', '8304205', '16692816', '16782931', '11368020', '9614953', '14317183', '8156802', '16692879', '11212432', '2856601', '12654248', '17299115', '6837934', '9524912', '17635028', '10925789', '17159905', '2635491', '10999529', '16611051', '6706924', '17594101', '7042813', '10745599', '16127748', '10745608', '16791310', '15734548', '7206677', '10655516', '15734562', '17700644', '8140580', '7116584', '16693036', '6510382', '17225521', '11007796', '9369405', '17160005', '17160011', '10057554', '16160597', '12195669', '16430936', '17471329', '17012579', '1963900', '16430973', '11270013', '10090368', '16013185', '17160066', '17446788', '17160070', '16734091', '17635212', '5322638', '16414607', '15619985', '16840593', '16693138', '16791445', '17471383', '16693145', '16693150', '14817184', '10278832', '11270071', '7239615', '12253124', '8247236', '10229713', '11589588', '17373147', '3012586', '7280618', '1628160', '7362573', '17635349', '15824919', '16414746', '17373220', '9525303', '10786871', '16046135', '17373242', '9041979', '17389637', '10295391', '17651815', '17651816', '16046186', '12974188', '16750706', '12580984', '17594496', '10811523', '6862990', '7592079', '11237520', '17635472', '2324624', '17037461', '16046235', '9771163', '7887004', '17651870', '1554607', '17021108', '3537085', '10361033', '10328267', '16046283', '11278541', '6478047', '17561828', '17651941', '15022312', '17717487', '17307890', '6559990', '17479932', '17037571', '12466441', '16218386', '15464727', '15702307', '8296742', '8075578', '16824639', '16963905', '9722178', '17373514', '5978446', '17439060', '16906583', '13900141', '15620462', '16669045', '7330176', '14809497', '16218522', '17332658', '9697726', '12433857', '17390020', '9951693', '2914769', '3586521', '17652191', '3783141', '15563241', '16120299', '16505333', '17258998', '17644029', '16128513', '3766786', '9484813', '17553935', '13539856', '15882770', '14809621', '6461981', '12794403', '17652269', '16898610', '16079417', '16693823', '13277759', '2161219', '17037896', '17603145', '7453281', '17635939', '8108647', '11893360', '17267312', '12827252', '17652341', '11582069', '7543414', '17267334', '13925004', '17111695', '12180115', '3816095', '17472166', '11893418', '10099380', '16865989', '15555272', '16161492', '16095972', '2734821', '8190698', '17038063', '17562353', '12057333', '17373944', '5348088', '16718595', '11049732', '3234569', '8534796', '3103501', '10959628', '16317201', '11819802', '10787613', '17038116', '7953188', '16530218', '17038124', '10902323', '17636154', '17333053', '17382210', '13794121', '16317273', '5659484', '13548387', '17382244', '13933413', '12745578', '17693549', '12098414', '10296178', '8698740', '17562499', '3079051', '13409177', '17087401', '13294518', '15899585', '3382211', '17652677', '3267527', '17316812', '17415121', '17013720', '17578970', '9157595', '3070940', '11860963', '9452516', '17472487', '16686056', '8322036', '7511033', '16497660', '17546236', '16612351', '16178175', '10656775', '3005449', '16325646', '10755086', '17415183', '17087506', '5151763', '9763874', '4291622', '15997992', '4799529', '16645163', '17267759', '10517563', '15916094', '12532802', '16620635', '4570211', '5954675', '16546935', '2153593', '12049530', '16325757', '16645253', '16694406', '14630036', '16325784', '16325785', '17333415', '13196458', '12188847', '17366193', '6552755', '16415926', '4889782', '3751105', '15842498', '17366219', '9501903', '16866514', '2170067', '11517143', '11418839', '11246807', '10960087', '7396574', '17308902', '10083576', '16850171', '16678155', '17718539', '16440606', '16547104', '16719137', '16858405', '14163240', '16850217', '5946678', '10755386', '17399104', '17718595', '16178504', '15998281', '7372107', '16899405', '17087822', '8944975', '2121047', '17399142', '16645481', '16883051', '16964971', '14859633', '7396722', '16440700', '16129405', '7396734', '15613322', '2784654', '7396751', '17317266', '17087893', '6282646', '16858520', '7396763', '17317276', '16645533', '16645534', '16645535', '16645536', '16162211', '14163375', '16162226', '14638516', '16006581', '16080309', '8936890', '16858554', '15998399', '16899522', '1605059', '15998405', '14056909', '17415639', '17391066', '17112542', '10329566', '12860894', '14163430', '10862065', '10681843', '16621053', '15851005', '17391103', '16678399', '10583550', '17448457', '17505802', '17276432', '14728725', '12181017', '13073957', '17571368', '17391146', '11009592', '17120833', '16694849', '7413327', '16096852', '5553750', '12222045', '16162398', '10559084', '17374829', '2293358', '16531061', '4447865', '14728832', '16613001', '16162441', '16875164', '13262493', '13811357', '16768670', '16883366', '17235625', '12345001', '14737073', '5611191', '17301176', '1670842', '16965315', '3653316', '1851081', '14106316', '15670989', '17333967', '9043664', '16735956', '15810262', '16441062', '17137384', '17325802', '16162541', '16367344', '17334006', '16367357', '10387197', '10829574', '13451024', '16080657', '16965394', '15916822', '16695065', '17506077', '17088289', '6496044', '14073652', '17006391', '16465721', '10723129', '16367419', '8232771', '17301324', '6594385', '16555870', '17268574', '16965471', '17276769', '17071970', '11067230', '9297764', '16465774', '17088367', '15875953', '10231669', '17301375', '16555905', '17047430', '17457030', '17178506', '17047435', '16056203', '7167884', '9510803', '13729683', '16023453', '7094183', '16441264', '10657712', '9027512', '16760763', '14426048', '17711044', '17457093', '10928069', '17268699', '12697572', '8970216', '16859117', '15556603']
        for sku in a:
            sql = """
            SELECT id FROM m_allegro_attribute c WHERE  c.CustomerId=1 and c.CategoryId=(	
	sELECT OtherNodeId
FROM m_allegro_sku_marketcategory WHERE sku =%s) AND c.Required=1 AND c.`Name`='Brand' AND c.CustomValuesEnabled=0
            """
            res = self.znkd_db.fetch_all_tuple(sql ,(sku,))
            if len(res):
                print()






if __name__ == '__main__':
    TestA().test_()
